// https://leetcode.cn/problems/special-positions-in-a-binary-matrix/
// 2022-9-4
#include <iostream>
#include <vector>

using namespace std;

class Solution {
public:
    int numSpecial(vector<vector<int>>& mat) {
		int r = mat.size();
		int c = mat[0].size();
		vector<int> rSum(r);
		vector<int> cSum(c);
		for(int i = 0; i < r; i++){
			for(int j = 0; j < c; j++){
				rSum[i] += mat[i][j];
				cSum[j] += mat[i][j];
			}
		}
		int res = 0;
		for(int i = 0; i < r; i++){
			if(rSum[i] != 1) continue;
			for(int j = 0; j < c; j++){
				if(mat[i][j] == 1 && cSum[j] == 1) res++;
			}
		}
		return res;
    }
};


int main(){
	Solution so;
	vector<vector<int>> pairs  = {
		{1,0,0},
		{0,0,1},
		{1,0,0}};
	cout << so.numSpecial(pairs);
	return 0;
}